feat: Support dashboard variables in chart builder tiles - #2901
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 60025e3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
5531572 to
9df95f9
Compare
E2E Test Results✅ All tests passed • 299 passed • 1 skipped • 1134s
Tests ran across 4 shards in parallel. |
Greptile SummaryThis PR extends dashboard-variable support from raw SQL charts to chart-builder tiles.
Confidence Score: 5/5The PR appears safe to merge because no blocking failure remains within the eligible follow-up-review scope. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| packages/common-utils/src/variables.ts | Adds shared token scanning, reference validation, language-aware builder-field traversal, and chart-config variable substitution. |
| packages/common-utils/src/core/renderChartConfig.ts | Substitutes dashboard variables before the existing builder chart rendering pipeline. |
| packages/app/src/DBDashboardPage.tsx | Supplies referenced dashboard variables to builder tiles and provides editor-wide variable completions. |
| packages/app/src/components/SQLEditor/variableCompletions.tsx | Centralizes variable and variable-macro completion generation and React context propagation. |
| packages/app/src/components/SQLEditor/variableValidation.tsx | Adds non-blocking validation indicators for variable references in expression editors. |
| packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx | Integrates dashboard variables into builder preview configuration and editor behavior. |
| packages/app/tests/e2e/features/dashboard.spec.ts | Exercises dashboard variable substitution, autocomplete, validation, and builder-tile behavior. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Filters[Dashboard filters and variable selections] --> Context[Chart variable context]
Context --> Editor[Builder expression editors]
Context --> Tile[Saved builder tile]
Editor --> Completion[Autocomplete and validation]
Tile --> References[Referenced-variable filtering]
References --> Config[Builder chart config with variables]
Config --> Substitute[Language-aware variable substitution]
Substitute --> Render[Chart config SQL rendering]
Render --> ClickHouse[(ClickHouse)]
Reviews (7): Last reviewed commit: "fix: Fix sample matching events variable..." | Re-trigger Greptile
9df95f9 to
9e8fb64
Compare
9e8fb64 to
b94023d
Compare
| case 'lucene': | ||
| return values.length === 0 | ||
| ? '*' | ||
| ? '("")' |
There was a problem hiding this comment.
This is a no-op (1=1), whereas * is a notEmpty(...)
| }; | ||
|
|
||
| /** What `snippet` expands to against the variable's current selection. */ | ||
| function describeVariableExpansion( |
There was a problem hiding this comment.
All this stuff has been moved to packages/app/src/components/SQLEditor/variableCompletions.tsx
| * the user through `resolveRawSqlMacros` — except when there is no context at | ||
| * all, in which case they silently pass through and are reported here. | ||
| */ | ||
| function validateVariableReferences(chartConfig: RawSqlChartConfig): { |
There was a problem hiding this comment.
Moved to packages/common-utils/src/variables.ts
b94023d to
d59161d
Compare
🔴 Tier 4 — CriticalTouches authentication, tenancy data models, the public API or shipped database config — or substantially changes the query rendering engine, background tasks, the OTel pipeline, image build, or release CI. Why this tier:
Additional context: touches the query rendering engine lightly (19 lines, under the 150-line bar for Tier 4) Review process: Deep review from a domain expert. Synchronous walkthrough may be required. Stats
|
Deep Review✅ No critical issues found. The core template engine ( 🟡 P2 — recommended
🔵 P3 nitpicks (3)🔵 P3 nitpicks (3)
Reviewers (12): correctness, security, adversarial, testing, maintainability, kieran-typescript, api-contract, performance, julik-frontend-races, project-standards, agent-native, learnings-researcher. Testing gaps: Confirm the |
d59161d to
e797e6b
Compare
e797e6b to
498e5fb
Compare
2e1a153 to
60025e3
Compare
Summary
This PR extends dashboard variable support to Builder charts.
Note that creation of variables is gated behind
NEXT_PUBLIC_ENABLE_DASHBOARD_VARIABLES(enabled by default in development locally.Future work
Future work includes, but is not limited to:
Screenshots or video
Screen.Recording.2026-08-13.at.12.21.41.PM.mov
How to test locally
NEXT_PUBLIC_ENABLE_DASHBOARD_VARIABLES=trueReferences